#include <iostream>
#include <cstring>
#include <queue>
#include <map>
#include <vector>
#include <string.h>
using namespace std;

int N, M;
int x, y;
const int MAXN = 1e5 + 10;
vector<int> g[MAXN];
queue<int> q;
int ans[MAXN];

void bfs(int i)
{
    bool vis[MAXN]={0};
    q.push(i);
    ans[i] = i;
    vis[i] = true;
    while (!q.empty())
    {
        int u = q.front();
        q.pop();
        for (int j = 0; j < g[u].size(); j++)
        {
            if (!vis[g[u][j]])
            {
                if(ans[g[u][j]] == 0) ans[g[u][j]] = i;
                vis[g[u][j]] = true;
                q.push(g[u][j]);
            }
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> N >> M;
    for (int i = 1; i <= M; i++)
    {
        cin >> x >> y;
        g[y].push_back(x);
    }
    for (int i = N; i >= 1; i--)
    {
        if(ans[i]==0) bfs(i);
    }
    for (int i = 1; i <= N; i++)
    {
        cout << ans[i] << " ";
    }
    //system("pause");
    return 0;
}